#include<stdio.h>

int main()
{
	int m, n;
	scanf("%d%d", &m, &n);
	int arr[101][101];
	int i, j;
	int len, max;
	int start, end;
	int s_max, e_max;
	int flag, flag_1;
	for (i = 0; i < m; i++)
	{
		for (j = 0; j < n; j++)
		{
			scanf("%d", &arr[i][j]);
		}
	}
	
	for (i = 0; i < m; i++)
	{
		flag = 0, flag_1 = 0;
		len = max = 0;
		start = end = 0;
		s_max = e_max = 0;
		for (j = 0; j < n; j++)
		{
			if (arr[i][j] == 1)
			{
				len++;
				if (flag == 0)
				{
					start = end = j;
					flag = 1;
					flag_1 = 1;
				}
				else
				{
					end++;
				}
				
				if (len == j+1)
				{
					s_max = 0;
					e_max = j;
				}
			}
			else
			{
				if (max <= len)
				{
					max = len;
					s_max = start;
					e_max = end;
				}
				len = 0;
				start = end = 0;
				flag = 0;
			}
		}
		if (flag_1 == 1)
		{
			printf("%d %d\n", s_max, e_max);
		}
		else
		{
			printf("-1 -1\n");
		}
	}
	
		
	return 0;
}


